#include "iostream"

using namespace std;

void swap01(int a,int b){
    int temp = a;
    a = b;
    b = temp;
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
}

void swap02(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main(){
	//指针和函数
    //1.值传递
    int a = 10;
    int b = 20;
    swap01(a,b);
    cout << "swap01 a = " << a << endl;
    cout << "swap01 b = " << b << endl;
    //2.地址传递 
    //如果是地址传递，可以修改实参
    swap02(&a,&b);
    cout << "swap02 a = " << a << endl;
    cout << "swap02 b = " << b << endl;
	system("pause");
	return 0;
}

